﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CoffeeMobile.Models;

namespace CoffeeMobile.Controllers
{
    public class FoodGroupsController : BaseController
    {
        private FoodGroupsRepository _foodGroupsRepository = new FoodGroupsRepository();
        //
        // GET: /FoodGroups/

        public ActionResult Index()
        {
            ViewBag.FoodGroups = _foodGroupsRepository.GetFoodGroups();
            return View();
        }
        public ActionResult Create()
        {
            return View();
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(AddNewFoodGroupModel model)
        {
            if (ModelState.IsValid)
            {
                FoodGroup entity = new FoodGroup();
                entity.ID = Guid.NewGuid();
                entity.Name = model.Name;
                entity.CreateDate = DateTime.Now;
                _dbLinq.FoodGroups.InsertOnSubmit(entity);
                _dbLinq.SubmitChanges();
                return RedirectToAction("Index");
            }

            else
            {
                return View(model);
            }
        }
        public ActionResult Edit()
        {
            return View();
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(int id, FormCollection collection)
        {
            return View();
        }
        public ActionResult Delete(int id)
        {
            return View();
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete(int id, FormCollection collection)
        {
            return View();
        }
    }
}
